package servlet;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com.google.gson.Gson;

import biz.AreaBiz;
import biz.impl.AreaBizImpl;
import entity.Area;

/**
 * Servlet implementation class queryStreetListServlet
 */
@WebServlet("/queryStreetList")
public class queryStreetListServlet extends HttpServlet {
	private static final long serialVersionUID = 1L;
       
    
	protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		String area = request.getParameter("areaId");
		int areaId=1;
		if(area!=null&&!area.isEmpty()){
			areaId=Integer.valueOf(area);
		}
		AreaBiz areaBiz = new AreaBizImpl();
		Area areaInfo = areaBiz.queryStreetOfAreaByAreaId(areaId);
		Gson gson =new Gson();
		String json = gson.toJson(areaInfo);
		response.getWriter().println(json);
		response.getWriter().flush();
		response.getWriter().close();
	}

	/**
	 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doGet(request, response);
	}

}
